import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';
import { Row,Col,Select,message,Card,Table} from 'antd';
import styles from '../pointroad/index.less';
const Option = Select.Option;

export default connect(({ production, loading }) => ({ production, loading }))(({production, dispatch,loading})=>
    <div className={styles.container}><PagesPOST dispatch={dispatch} {...production} loading={loading.global}/></div>);

class PagesPOST extends React.Component {

    //查询数据
    componentWillMount () {
        this.props.dispatch({type:"production/goList",payload:{id:localStorage.getItem('id')}});
    }

    render (){
        const columns = [
            {
                title: '检查类型',
                dataIndex: 'item_type',
                render:text => text && text == '1'?'选择检查':"数字检查",
            },
            {
                title: '项目名称',
                dataIndex: 'item_name',
            },
            {
                title: '检查结果',
                dataIndex: 'address',
            },
            {
                title: '文本描述',
                dataIndex: 'item_explain',
            },
            {
                title: '照片',
                dataIndex: 'address3',
            },
            {
                title: '是否合格',
                dataIndex: 'istrue',
                render:text => text && text == '1'?'合格':"不合格",
            },
            {
                title: '评分',
                dataIndex: 'itemdetailnum',
            },
        ];
        let {getProductionListData} = this.props;
        const Data = getProductionListData?getProductionListData:{};
        Data.details && Data.details.map((item,index) => item.index = index);
        return (<div>
            <Card
                type="inner"
                title="巡检记录单"
            >
                <div style={{borderBottom:"2px solid #f5f5f5",marginBottom:14}}>
                    <b>基本信息</b>
                    <Row style={{margin:20}}>
                        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>巡检人员:</b>{Data.userName}</Col>
                        <Col xs={{ span: 11, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>完成状态:</b></Col>
                        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>所属部门:</b>{Data.s_name}</Col>
                    </Row>
                    <Row style={{margin:20}}>
                        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>巡检时间:</b>{Data.checkTime}</Col>
                        <Col xs={{ span: 11, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>巡检结果:</b></Col>
                        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>评分:{Data.total}</b></Col>
                    </Row>
                </div>
                <div style={{borderBottom:"2px solid #f5f5f5",marginBottom:14}}>
                    <b>任务信息</b>
                    <Row style={{margin:20}}>
                        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>巡检计划名称:</b>{Data.plan_name}</Col>
                        <Col xs={{ span: 11, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>巡检点编号:</b>{Data.pointNum}</Col>
                        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>巡检点名称:</b>{Data.pointName}</Col>
                    </Row>
                    <Row style={{margin:20}}>
                        <Col xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}><b>任务编号:</b></Col>
                    </Row>
                </div>
                <div>
                    <b>检查项目</b>
                    <Table style={{marginTop:14}} rowKey={id => id.index} columns={columns} dataSource={ Data.details || null} />
                </div>
            </Card>
        </div>);
    }
}
